<?php

if (!defined('WPSR_ACCESS')) { exit; }


/**
 * WP Showroom Admin Page - Manage Galleries & Pictures
 *
 * @package
 */


require_once "wpsr.admin.php";


$wpsr = new WPsrAdm;
$wpsr->WPsrUser();

$id = 1;
$depth = 0;

$allalb = $wpsr->getAlbList();


$pics = false;
if ($_GET['picture'] == "Pictures") {
	$pics = true;
}


/**
 * Show Manage Pictures
 */
if ($_GET['wpsrdo'] == 'pictures' || $pics == true) {
	$album = (int) $_GET['faid'];

	$wpsr->obj = $wpsr->getAlbById($album);
	$wpsr->path = $wpsr->getPath($wpsr->obj->id);
	$wpsr->AdmSecurityManager();

	$wpsr->pictures = $wpsr->getPictures();

	//printf('<pre>%s</pre>', print_r($wpsr->pictures, true));

/*
	if ( count($wpsr->error) < 1 ) {
		$wpsr->albums = $wpsr->getAlbums($id, 0, $depth);
	}
*/

	$wpsr->getAdminMessage();
?>

	<div class="wrap">
<?php
		if ( count($wpsr->error) < 1 ) {
			$wpsr->adminManagePictureOutput($wpsr, $allalb);
		}
		$wpsr->adminFooter();
?>
	</div>
<?php

}


/**
 * Show Manage Galleries
 */
else {

	if ($_GET && $_GET['event'] == 'filter') {
		$id = (int) $_GET['faid'];
	}
	
	$wpsr->obj = $wpsr->getAlbById($id);
	$wpsr->path = $wpsr->getPath($wpsr->obj->id);
	$wpsr->AdmSecurityManager();

	if ( count($wpsr->error) < 1 ) {
		if ($id == 1) {
			$wpsr->albums = $wpsr->getAlbums($id, 0, $depth);
			
		}
		else {
			$wpsr->albums = $wpsr->getAlbums($wpsr->obj->id, 0, $depth);

		}
	}

	$wpsr->getAdminMessage();
?>

	<div class="wrap">
<?php
		// printf('<pre>%s</pre>', print_r($wpsr->albums, true));
		if ( count($wpsr->error) < 1 ) {
			$wpsr->adminManageOutput($wpsr, $allalb, $id);
		}
		$wpsr->adminFooter();
?>
	</div>
<?php
}
?>
